import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      external: ['element-plus/dist/index.css'],
      output: {
        dir: 'dist',
      },
    },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    proxy: {
      // 仅代理以 /geoconv/v2/ 开头的请求到 https://api.map.baidu.com
      '/geoconv/v2/': {
        target: 'https://api.map.baidu.com',
        changeOrigin: true,
        rewrite: (path) => path, // 保持路径不变
      },
      // '/poi':{
      //   target: 'http://localhost:9090',
      //   changeOrigin: true,
      //   rewrite: (path) => path.replace(/^\/poi/, ''),
      // }
    },
  },
})
